package anthology.daily_question._25_01;
//https://leetcode.cn/problems/number-of-changing-keys/description/?envType=daily-question&envId=2025-01-07
public class _3019按键变更的次数 {
    class Solution {
        public int countKeyChanges(String s) {
            int ans = 0;
            for (int i = 1; i < s.length(); ++i) {
                if (Character.toLowerCase(s.charAt(i - 1)) != Character.toLowerCase(s.charAt(i))) {
                    ++ans;
                }
            }
            return ans;
        }
    }
    class Solution2 {
        public int countKeyChanges(String s) {
            int ans = 0;
            for(int i = 0; i < s.length()-1; i++){
                if(!(s.charAt(i) == s.charAt(i+1)
                        || Math.abs(s.charAt(i) - s.charAt(i+1)) == 32)){
                    ans++;
                }
            }
            return ans;
        }
    }
}
